﻿using System;
using System.Threading.Tasks;

namespace Innovative.Atom.Timer.Event
{
	public sealed class AtomSingleEvent : AtomEvent
	{
		public AtomSingleEvent(DateTime eventDateTime)
			: base()
		{
			// ***
			// *** The Single Event object only fires once
			// *** at the specified date and time
			// ***
			this.EventDateTime = eventDateTime;
		}

		public AtomSingleEvent(DateTime eventDateTime, Task<bool> eventTask)
			: base(eventTask)
		{
			// ***
			// *** The Single Event object only fires once
			// *** at the specified date and time
			// ***
			this.EventDateTime = eventDateTime;
		}

		public AtomSingleEvent(string eventName, DateTime eventDateTime, Task<bool> eventTask)
			: base(eventName, eventTask)
		{
			// ***
			// *** The Single Event object only fires once
			// *** at the specified date and time
			// ***
			this.EventDateTime = eventDateTime;
		}

		public AtomSingleEvent(string eventName, DateTime eventDateTime)
			: base(eventName)
		{
			// ***
			// *** The Single Event object only fires once
			// *** at the specified date and time
			// ***
			this.EventDateTime = eventDateTime;
		}

		protected override void OnUpdateNextEventDateTime()
		{
			// ***
			// *** This task is about to be run. Since this task only 
			// *** executes once it is marked expired.
			// ***
			this.TaskIsExpired = true;
		}
	}
}
